import React, { useState } from 'react';
import { DatePicker } from 'antd';

const YearPicker = ({ value, onChange, ...rest }) => {
    const [open, setOpen] = useState(false);
    return (
        <DatePicker
            open={open}
            value={value}
            onPanelChange={date => {
                onChange(date);
                setOpen(false);
            }}
            mode="year"
            format="YYYY"
            onOpenChange={status => {
                setOpen(status);
            }}
            {...rest}
        />
    );
};

export default YearPicker;
